from uitls.get_by_local import GetByLocal
import time
from selenium.webdriver.support import expected_conditions as EC  #条件判断
from selenium.webdriver.support.ui import WebDriverWait
from base.base_driver import BaseDriver
class LoginPage:
    # 获取登录页面所有的页面元素信息
    def __init__(self,i):
        base_driver=BaseDriver()
        print('LoginPage--------------',i)
        self.driver=base_driver.android_driver(i)
        self.get_by_local=GetByLocal(self.driver)
    def get_navbar_element(self):
        #底部导航栏"我的"按钮
        return self.get_by_local.get_element('navbar')

    def get_my_element(self):
        #侧边栏"我的"按钮
        return self.get_by_local.get_element('my')

    def get_username_element(self):
        #输入手机号输入框
        return self.get_by_local.get_element('username')

    def get_password_element(self):
        #输入密码输入框
        return self.get_by_local.get_element('password')

    def get_login_button_element(self):
        #登录按钮
        return self.get_by_local.get_element('login_button')

    def get_tost_element(self,message):
        #获取tost_element
        time.sleep(2)
        tost_element = ("xpath", "//*[contains(@text,"+message+")]")
        loginButtonElement = WebDriverWait(self.driver, 10, 0.1).until(EC.presence_of_element_located(tost_element))
        print(loginButtonElement.text)